package com.hanxry.simple;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import java.util.UUID;

/**
 * MDC 多线程示例
 *
 * @author hanxry
 */
public class SimpleDemo {
    private static final Logger logger = LoggerFactory.getLogger(TheadDemo.class);

    public static final String TRACE_ID = "traceId";

    public static void main(String[] args) {
        MDC.put(TRACE_ID, UUID.randomUUID().toString());
        logger.info("开始调用，进行业务处理");
        logger.info("处理完毕，释放空间，避免内存泄露");
        MDC.remove(TRACE_ID);
        logger.info("TRACE_ID 还在吗？ {}", MDC.get(TRACE_ID) != null);

    }
}
